package net.hailxenu.stats;

import java.util.HashMap;
import java.util.Scanner;
import java.io.*;

public class Configuration
{
    private HashMap<String, Object> Config;
    public Configuration( File file )
    {
        try
        {
            Config = new HashMap<String, Object>();
            Scanner in = new Scanner(file);

            while(in.hasNextLine())
            {
                String x = in.nextLine().replace(" ", "");

                String[] infoz = x.split(":");
                if(infoz.length > 1)
                {
                    Config.put(infoz[0].replaceAll(":", ""), infoz[1].replaceAll(":", ""));
                }
            }
        } catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    public boolean hasKey(String name)
    {
        return Config.containsKey(name);
    }

    public String getString(String name)
    {
        if(!hasKey(name))
        {
            return null;
        }
        return (String)Config.get(name);
    }

    public Integer getInt(String name)
    {
        if(!hasKey(name))
        {
            return null;
        }
        return Integer.parseInt(((String)Config.get(name)).replaceAll(" ", ""));
    }
}